package chapter8.section8;

//程序8-11：三种生成Stream流的方式
import java.util.*;
import java.util.stream.Stream;

public class GenerateStream {
	public static void main(String[] args) {
		// Collection体系的集合可以使用默认方法stream()生成流
		// default Stream< E > stream()
		List<String> list = new ArrayList<String>();
		list.stream();

		Set<String> set = new HashSet<String>();
		set.stream();

		// Map体系的集合间接的生成流
		Map<String, Integer> map = new HashMap<String, Integer>();
		Stream<String> keyStream = map.keySet().stream();
		Stream<Integer> valueStream = map.values().stream();
		Stream<Map.Entry<String, Integer>> entryStream = map.entrySet().stream();

		// 数组可以通过Stream接口的静态方法of(T...values)生成流
		String[] str = { "Hello", "World", "Java" };
		Stream<String> strStream = Stream.of(str);
		Stream<String> strStream2 = Stream.of("hello", "world", "java");
		Stream<Integer> intStream = Stream.of(10, 20, 30);
	}
}